/*
    localStorage存储数据
*/
export const setItem = (key,value) =>{
    // 只能存储为字符串
    if(typeof value === 'object'){
        value = JSON.stringify(value);
    }
    localStorage.setItem(key,value);
}

export const getItem = (key) =>{
    const data = localStorage.getItem(key);
    // 如果转换出错，就说明数据不是对象类型，之间返回
    try{
        return JSON.parse(data)
    }catch(err){
        return data;
    }
}
export const removeItem = (key) =>{
    localStorage.removeItem(key);
}

export const isArray = obj => Object.prototype.toString.call(obj) === "[object Array]";